<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var getRow = function(rowIndex) {
        if(rowIndex == 0)return [[1]];
        let triangle = [[1]],current;
        for(let i=0; i <= rowIndex-1; i++){
            current = [1];
            for(let j=0; j<i; j++){
                current.push(triangle[i][j] + triangle[i][j+1]);
            }
            current.push(1);
            triangle.push(current);
        }
        return current;
    };
    console.log(getRow(5));
    
</script>
</html>